<?php

namespace common\models;

use Yii;
use \common\base\BaseActiveRecord;

/**
 * This is the model class for table "{{%news}}".
 *
 * @property integer $id
 * @property integer $category_id
 * @property string $title
 * @property string $litpic
 * @property string $desc
 * @property string $content
 * @property string $tag
 * @property string $author
 * @property string $comefrom
 * @property string $remark
 * @property integer $views
 * @property integer $shares
 * @property integer $order
 * @property integer $status
 * @property integer $version
 * @property string $created_by
 * @property integer $created_at
 * @property string $created_from
 * @property string $created_ip
 * @property string $updated_by
 * @property integer $updated_at
 * @property string $updated_from
 * @property string $updated_ip
 * @property integer $is_deleted
 */
class News extends BaseActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%news}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['category_id', 'order', 'views', 'shares', 'status', 'version', 'created_at', 'updated_at', 'is_deleted'], 'integer'],
            [['title','category_id'], 'required'],
            [['content'], 'string'],
            [['title', 'desc', 'author', 'comefrom'], 'string', 'max' => 100],
            [['litpic', 'tag', 'remark'], 'string', 'max' => 200],
            [['created_by', 'created_from', 'created_ip', 'updated_by', 'updated_from', 'updated_ip'], 'string', 'max' => 50],
            ['order', 'default', 'value' => 0],
            ['status', 'default', 'value' => self::STATUS_FLAG_NORMAL],
            ['status', 'in', 'range' => [self::STATUS_FLAG_TEMP, self::STATUS_FLAG_NORMAL, self::STATUS_FLAG_STOP]],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'id'),
            'category_id' => Yii::t('common', 'category_id'),
            'title' => Yii::t('common', 'title'),
            'litpic' => Yii::t('common', 'litpic'),
            'desc' => Yii::t('common', 'desc'),
            'content' => Yii::t('common', 'content'),
            'tag' => Yii::t('common', 'tag'),
            'author' => Yii::t('common', 'author'),
            'comefrom' => Yii::t('common', 'comefrom'),
            'remark' => Yii::t('common', 'remark'),
            'status' => Yii::t('common', 'status'),
            'views' => Yii::t('common', 'views'),
            'shares' => Yii::t('common', 'shares'),
            'order' => Yii::t('common', 'order'),
            'version' => Yii::t('common', 'version'),
            'created_by' => Yii::t('common', 'created_by'),
            'created_at' => Yii::t('common', 'created_at'),
            'created_from' => Yii::t('common', 'created_from'),
            'created_ip' => Yii::t('common', 'created_ip'),
            'updated_by' => Yii::t('common', 'updated_by'),
            'updated_at' => Yii::t('common', 'updated_at'),
            'updated_from' => Yii::t('common', 'updated_from'),
            'updated_ip' => Yii::t('common', 'updated_ip'),
            'is_deleted' => Yii::t('common', 'is_deleted'),
        ];
    }
}
